import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
  state: () => ({
    userInfo: null,
    isLogin: false,
  }),
  
  actions: {
    setUserInfo(userInfo) {
      this.userInfo = userInfo
      this.isLogin = !!userInfo
    },
    
    async login(userInfo) {
      this.setUserInfo(userInfo)
    },
    
    async logout() {
      this.setUserInfo(null)
    }
  },
  
  getters: {
    getUserInfo: (state) => state.userInfo,
    getLoginStatus: (state) => state.isLogin
  }
}) 